package reflect;

import java.lang.reflect.Method;

//暴力反射
public class ReflectDemo7 {
    public static void main(String[] args) throws Exception{
        Class cls = Class.forName("reflect.Person");
        Object obj = cls.newInstance();//Person p = new Person();

        Method method = cls.getDeclaredMethod("hehe");
        method.setAccessible(true);//强制打开访问权限
        method.invoke(obj);//调用hehe()方法
        method.setAccessible(false);//关闭访问权限
    }
}
